QuickTime 3 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Executing the Decompression Sequence

With the effect and sample descriptions built and the decompression sequence prepared, you can now execute the effect. The function shown in Listing 17 executes a single frame of a decompression sequence.

The parameter theTime contains the number of the frame to be executed. The parameter theNumberOfSteps contains the total number of frames that will be used to run the effect.

Listing 17 The RunEffect function, which executes one frame of an effect

// Decompress a single step of the effect sequence at time.
OSErr RunEffect(TimeValue theTime, int theNumberOfSteps)
{
    OSErr                   err = noErr;
    ICMFrameTimeRecord      frameTime;

    // Set the timebase time to the step of the sequence to be rendered
    SetTimeBaseValue(gTimeBase, theTime, theNumberOfSteps);

    frameTime.value.lo      = theTime;
    frameTime.value.hi      = 0;
    frameTime.scale         = theNumberOfSteps;
    frameTime.base          = 0;
    frameTime.duration      = theNumberOfSteps;
    frameTime.rate          = 0;
    frameTime.recordSize    = sizeof(frameTime);
    frameTime.frameNumber   = 1;
    frameTime.flags         = icmFrameTimeHasVirtualStartTimeAndDuration;
    frameTime.virtualStartTime.lo   = 0;
    frameTime.virtualStartTime.hi   = 0;
    frameTime.virtualDuration   = theNumberOfSteps;

    HLock(myEffectDesc);
    DecompressSequenceFrameWhen(gEffectSequenceID,
                            StripAddress(*myEffectDesc),
                            GetHandleSize(myEffectDesc),
                            0,
                            0,
                            nil,
                            &frameTime);
    HUnlock(myEffectDesc);
}

The code in Listing 18 executes an effect in 30 steps.

Listing 18 Executing an effect directly by calling RunEffect

for (currentTime = 0; currentTime < 30; currentTime++)
{
    myErr = RunEffect(currentTime, 30);
    if (myErr != noErr)
        goto bail;
}

© 1998 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |